import { Breadcrumb } from "antd";
import { useLocation } from "inula-router";
import { useEffect, useState } from "openinula";

export default function BreadCrumb() {
  const location = useLocation();
  const [items, setItems] = useState([]);

  useEffect(() => {
    const pathname = location.pathname;
    const temporyItems = [];
    switch (pathname) {
      case '/app/one': temporyItems.push({ title: '应用1' }); break;
      case '/app/two': temporyItems.push({ title: '应用2' }); break;
      case '/app/three': temporyItems.push({ title: '应用3' }); break;
      case '/set/android': temporyItems.push({ title: '配置应用' }, { title: 'Android' }); break;
      case '/set/app': temporyItems.push({ title: '配置应用' }, { title: 'App' }); break;
      default: { }
    }
    setItems([...temporyItems])
  }, [location])
  return <Breadcrumb
    className="breadcrumb"
    items={items}
  />
}